@echo off
echo 🔍 正在测试远程仓库连接...
echo.

REM 常见Git安装路径
set "GIT_PATH=C:\Program Files\Git\bin\git.exe"
set "GIT_PATH2=C:\Program Files\Git\cmd\git.exe"
set "GIT_PATH3=C:\Program Files (x86)\Git\bin\git.exe"
set "GIT_PATH4=C:\Users\%USERNAME%\AppData\Local\Programs\Git\bin\git.exe"

REM 查找Git
if exist "%GIT_PATH%" (
    set "GIT_CMD="%GIT_PATH%""
    goto :found_git
)
if exist "%GIT_PATH2%" (
    set "GIT_CMD="%GIT_PATH2%""
    goto :found_git
)
if exist "%GIT_PATH3%" (
    set "GIT_CMD="%GIT_PATH3%""
    goto :found_git
)
if exist "%GIT_PATH4%" (
    set "GIT_CMD="%GIT_PATH4%""
    goto :found_git
)

echo ❌ 未找到Git安装
echo 📥 请确保已安装Git: https://git-scm.com/download/win
echo.
echo 或者手动在Git Bash中执行以下命令：
echo cd "/c/Users/Administrator/Documents/trae_projects/lt00001/magazine"
echo git remote -v
pause
exit /b 1

:found_git
echo ✅ 找到Git: %GIT_CMD%
echo.

REM 进入项目目录
cd /d "C:\Users\Administrator\Documents\trae_projects\lt00001\magazine"
echo 📁 当前目录: %cd%
echo.

echo 🔍 检查远程仓库配置...
%GIT_CMD% remote -v
echo.

echo 🔍 测试远程仓库连接...
%GIT_CMD% ls-remote --heads origin 2>nul
if %errorlevel% equ 0 (
    echo ✅ 远程仓库连接正常
) else (
    echo ❌ 远程仓库连接失败
    echo.
    echo 🔧 可能的解决方案：
    echo 1. 配置远程仓库：
    echo    git remote add origin https://gitee.com/你的用户名/magazine.git
    echo 2. 检查网络连接
    echo 3. 验证仓库地址是否正确
)
echo.

echo 🔍 检查当前分支...
%GIT_CMD% branch -a
echo.

echo 🔍 检查提交历史...
%GIT_CMD% log --oneline -5
echo.

echo 📋 测试完成！
pause